NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name [2015] OGame: Todas las clasificaciones en un tooltip // @author Capt Katana // @description OGame: Todas las clasificaciones en un tooltip que aparece al posar el mouse sobre la opción "Clasiciaciones" en el menú. (Requiere cerrar sesión y volver a iniciar para que haga la primera carga de datos) // @version 2015.1 // @date 2015-07-27 // @namespace clasificacion_en_tooltip // @include http://*.ogame.*/game/index.php?page=* // @exclude http://*.ogame.*/game/index.php?page=empire* // @grant GM_getValue // @grant GM_setValue // @grant GM_listValues // @grant GM_deleteValue // @grant unsafeWindow // @grant GM_getResourceText // @grant GM_addStyle // @grant GM_xmlhttpRequest // @grant GM_getResourceURL // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js // ==/UserScript== window.addEventListener("load", function(e) { /* básico */ this.$ = this.jQuery = jQuery.noConflict(true); if ( !$ ) { return; } if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported") != -1)) { this.GM_getValue = function(key, def){ return localStorage[key] || def; }; this.GM_setValue = function(key, value){ return localStorage[key] = value; }; this.GM_deleteValue = function(key){ return delete localStorage[key]; }; } var setValue = function(key, value) { GM_setValue(key, JSON.stringify(value)); } var getValue = function(key, def) { var value = GM_getValue(key); if (value === undefined) return def; return JSON.parse(value); } function getMetaContent(mn){ var m = document.getElementsByTagName('meta'); for(var i in m){ if(m[i].name == mn){ return m[i].content; } } return ""; } /* !básico */ function formatNumber(num) { return ("" + num).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, function($1) { return $1 + "." }); } function getData(_universe, _playerID, _type){ GM_xmlhttpRequest({ method: "POST", url: "http://" + _universe + "/api/highscore.xml?category=1&type=" + _type, /* "http://" + universe + "/api/highscore.xml?category=1&type=0" */ data: "category=1&type=" + _type, headers: { "Content-Type": "application/x-www-form-urlencoded" }, onload: function(response) { if (response.responseText.indexOf(_playerID) > -1) { var top = response.responseText.split('id="' + _playerID + '"')[0]; top = parseInt(top.substring(top.lastIndexOf('<player position="') + 18)); var puntaje = response.responseText.split('id="' + _playerID + '"')[1]; puntaje = (puntaje.split('score="')[1]).split('"')[0]; var clasificacion = formatNumber(top) + ' (' + formatNumber(puntaje) + ')'; if(_type == 3){ var naves = response.responseText.split('id="' + _playerID + '"')[1]; naves = formatNumber((naves.split('ships="')[1]).split('"')[0]); } var key = _universe + _type; var keyShips = _universe + 'ships'; setTimeout((function(){ GM_setValue(key, clasificacion); GM_setValue('timestamp', new Date().toLocaleTimeString()); if(_type == 3){ GM_setValue(keyShips, naves); } updateData(universe); }),0); } } }); } function updateData(_universe) { var timestamp = GM_getValue('timestamp'); var html = "<u>General</u>: "+ GM_getValue(_universe + '0') +"<br />"+ "<u>Economía</u>: "+ GM_getValue(_universe + '1') +"<br />"+ "<u>Investigación</u>: "+ GM_getValue(_universe + '2') +"<br />"+ "<u>Militar</u>: "+ GM_getValue(_universe + '3') +"<br />"+ "- <u>Naves</u>: "+ GM_getValue(_universe + 'ships')+"<br />"+ "- <u>Militar Construidos</u>: "+ GM_getValue(_universe + '5') +"<br />"+ "- <u>Militar Destruidos</u>: "+ GM_getValue(_universe + '6') +"<br />"+ "- <u>Militar Perdidos</u>: "+ GM_getValue(_universe + '4') +"<br />"+ "<u>Honor</u>: "+ GM_getValue(_universe + '7') +"<br /><br />" + "Actualizado: " + timestamp; document.getElementById('bar').innerHTML = (document.getElementById('bar').innerHTML).replace('index.php?page=highscore"', 'index.php?page=highscore" title="'+ html +'" class="tooltipCustom" style="color: lime !important;"'); } var universe = getMetaContent("ogame-universe"); updateData(universe); if (document.location.href.indexOf ("overview") > 0 || document.location.href.indexOf ("highscore") > 0){ var playerID = getMetaContent("ogame-player-id"); for (var i=0;i<=7;i++){ getData(universe, playerID, i); } } }, false);